<template>
	<view class="body" >
		<view class="header" >
			<view>
				<u-icon name="rmb-circle-fill" color="#fff" size="120" ></u-icon>
			</view>

			<view class="text1" >账户余额(元)</view>
			<view class="text2" >{{dataAmount.balance}}</view>
		</view>
		
		<view class="use-detail" >
			<view class="left item" >
				可提现金额
				<view>{{dataAmount.balance}}</view>
			</view>
			<view class="right item" >
				冻结金额
				<view>{{dataAmount.frozen_money}}</view>
			</view>
		</view>
		
		<!-- 占位用的 -->
		<view class="place" ></view>
		
		<!-- 充值或者提现开始 -->
		<view class="fund-view" @click="topup" >
			<view>{{isStore ? "提现" : "充值" }}</view>
			<u-icon name="arrow-right" color="#666" ></u-icon>
		</view>
		<!-- 充值或者提现结束 -->
		
		<!-- 更多信息开始 -->
		<view class="more-detail" >
			
			<view class="detail-item">
				<view>近30天记录</view>
				<!-- <view style="color: #666;" >更多</view> -->
			</view>
			
			<u-empty class='noView' v-if="list.length == 0" ></u-empty>
			<view class="detail-item" v-for="(item,index) in list" :key="index" >
				<view class="left-detail" >
					<view>{{item.remark}}</view>
					<view class="time" >{{item.time}}</view>
				</view>
				<view class="money" >{{item.money_string}}</view>
			</view>
			
			<u-loadmore v-if="list.length > 0" :status="status" ></u-loadmore>
			
		</view>
		<!-- 更多信息结束 -->
		
	</view>
</template>

<script>
	export default{
		
		data(){
			return{
				dataAmount: {}	,//账户资金
				list: []   ,//流水记录
				status: 'loadmore',
				page: 1,
				lastPage: 1,
				isStore: false,    //是否是店铺【false是普通用户，true是店铺用户】
 			}
		},
		onLoad() {
			this.getWallet()
			this.getType()
			this.getList()
			
		},
		methods:{
			getType(){
				this.$https.Mine.getStoreStatus().then(req => {
					switch(req.type){
						case 2:
						case 4:
						this.isStore = true
						break
						default:
						this.isStore = false
					}
					
				})
			},
			
			getWallet(){
				this.$https.Mine.getAmount('member').then(req => {
					this.dataAmount = req
				})
			},
			getList(){
			
				if(this.status == 'nomore' || this.status == 'loading'){
					return
				}
				this.status == 'loading'
				this.$https.Mine.waterRecord('member',this.page).then(req => {
					
					this.list = this.list.concat(req.data)
					this.lastPage = req.last_page
					this.page++
					this.status = this.page > this.lastPage ? 'nomore' : 'loadmore'
				})
			},
			onReachBottom(){
				this.getList()
			},
			topup(){  //充值提现的Action
			
				if(this.isStore){  //店铺--提现
					uni.navigateTo({
						url: './inOut?type=1&balence='+this.dataAmount.balance
					})
				}else{  //普通用户--充值
					uni.navigateTo({
						url: './inOut?type=2&balence='+this.dataAmount.balance
					})
				}
				
				// uni.navigateTo({
				// 	url: './inOut?type=1&balence='+this.dataAmount.balance
				// })
			}
		}
	}
	
</script>

<style lang="scss" >
	
	page,.body{
		
		position: relative;
		
		width: 100%;
		height: 100%;
		
		background-color: rgb(250,250,250);
	}
	
	.header{
		
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		
		height: 400rpx;
		background-color: #EF6060;
		
		text-align: center;
		
		color: #FFFFFF;
		
		.text1{
			padding: 14rpx 0;
			font-size: $uni-font-size-base;
		}
		
		.text2{
			font-size: 40rpx;
		}
	}
	
	.use-detail{
		
		position: absolute;
		top: 330rpx;
		
		display: flex;
		align-items: center;
		justify-content: space-evenly;
		
		margin: 0 20rpx;
		
		height: 160rpx;
		width: 95%;
		
		border-radius: 10rpx;
		background-color: #FFFFFF;
		
		.item{
			flex: 1;
			text-align: center;
			
			view{
				
				font-size: $uni-font-size-lg;
				color: $uni-color-error;
			}
		}
	}
	
	.place{
		height: 100rpx;
	}
	
	
	.fund-view{
		display: flex;
		justify-content: space-between;
		align-items: center;
		
		margin: 20rpx;
		padding: 0 30rpx;
		height: 70rpx;
		
		background-color: #FFFFFF;
		border-radius: 10rpx;
	}
	.more-detail{
		
		margin: 20rpx;
		padding-bottom: 30rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		
		.detail-item{
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			// padding: 20rpx 30rpx;
			margin: 0 30rpx;
			padding: 20rpx 0;
			
			border-bottom: 1rpx solid rgb(245,245,245);
			font-size: $uni-font-size-base;
			
			.money{
				
				color: rgb(110,198,124);
			}
			
			.left-detail{
				
				.time{
					color: #ccc;
				}
			}
		}
	}
	
	
</style>
